# $Id: PKGBUILD 89229 2013-04-28 06:44:16Z tpowa $
# Maintainer:  Thorsten Töpper <atsutane-tu@freethoughts.de>
# Contributor: SpepS <dreamspepser at yahoo dot it>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>

_extramodules=extramodules-3.8-ARCH
pkgname=ndiswrapper
pkgver=1.58
pkgrel=7
pkgdesc="Module for NDIS (Windows Network Drivers) drivers supplied by vendors."
license=('GPL')
arch=('i686' 'x86_64')
url="http://ndiswrapper.sourceforge.net"
install=ndiswrapper.install
depends=('linux>=3.8' 'linux<3.9' 'wireless_tools' 'perl')
makedepends=('linux-headers')
provides=("$pkgname-utils" "$pkgname-bin")
replaces=("$pkgname-utils" "$pkgname-bin")
source=("http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz")
options=('!strip')
sha1sums=('a256812b3136648ed93e04146d2276a3ca70957c')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  _kver="$(cat /usr/lib/modules/${_extramodules}/version)"

  # modinfo path fix
  sed -i "/modinfo/s/s/usr\//" driver/Makefile

  # make sure we point to the right build directory
  sed -i "/^KBUILD/ s,.*,KBUILD = $(readlink -f /usr/lib/modules/$_kver/build)," driver/Makefile

  make KVERS=$_kver
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  _kver="$(cat /usr/lib/modules/${_extramodules}/version)"

  make INST_DIR="usr/lib/modules/$_extramodules" \
    KVERS=$_kver DESTDIR="$pkgdir/" install

  gzip "$pkgdir/usr/lib/modules/$_extramodules/$pkgname.ko"
}

# vim:set ts=2 sw=2 et:
